package vue;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class DeleteContact extends JDialog{
	
	private JLabel name, lastname;
	private JTextField tname, tlastname;
	private List<String> tab ;
	
	/**
	 * Constructor
	 * @param parent
	 * @param title
	 * @param modal
	 */
	public DeleteContact(JFrame parent, String title, boolean modal) {
		 super(parent, title, modal);
		 this.setSize(340, 150);
		 this.setLocationRelativeTo(null);
		 this.setResizable(false);
		 this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		 tab = new ArrayList<String>();
		 this.init();
		 this.setVisible(true);
		 
	}  
	
	/**
	 * initialize graphic components
	 */
	private void init(){
		 JPanel pan = new JPanel();		 
		 name = new JLabel(AddressBook.FIRSTNAME);
		 name.setPreferredSize(new Dimension(130, 20));
		 lastname = new JLabel(AddressBook.LASTNAME);
		 lastname.setPreferredSize(new Dimension(130, 20));

		 tname = new JTextField();
		 tname.setPreferredSize(new Dimension(130, 20));
		 tlastname = new JTextField();
		 tlastname.setPreferredSize(new Dimension(130, 20));

		 pan.add(name);
		 pan.add(tname);
		 pan.add(lastname);
		 pan.add(tlastname);

		 JButton delete = new JButton("DELETE");
		 pan.add(delete);
		 delete.addActionListener(new ActionListener(){

				@Override
				public void actionPerformed(ActionEvent arg0) {
					// TODO Auto-generated method stub
					tab.add(tname.getText());
			         tab.add(tlastname.getText());
			         setVisible(false);
				}
			     });
		 this.getContentPane().add(pan);
	}

	/**
	 * @return the tab
	 */
	public List<String> getTab() {
		return tab;
	}


}
